﻿using System;
using System.Globalization;

namespace Eswat.Extensions.Strings
{
	/// <summary>
	/// Extensions for <see cref="System.String"/>.
	/// </summary>
	public static class StringExtensions
	{
		/// <summary>
		/// Replaces the tokens in the source format string with the specified arguments using the invariant culture format provider.
		/// </summary>
		/// <param name="value">The value.</param>
		/// <param name="args">The args.</param>
		/// <returns></returns>
		public static string FormatWith(this string value, params object[] args)
		{
			var str = value.FormatWith(CultureInfo.InvariantCulture, args);

			return str;
		}

		/// <summary>
		/// Replaces the tokens in the source format string with the specified arguments using the specified format provider.
		/// </summary>
		/// <param name="value">The value.</param>
		/// <param name="formatProvider">The format provider.</param>
		/// <param name="args">The args.</param>
		/// <returns></returns>
		public static string FormatWith(this string value, IFormatProvider formatProvider, params object[] args)
		{
			var str = string.Format(formatProvider, value, args);

			return str;
		}
	}
}
